package gu.sql2java.observer;

import static com.google.common.base.Preconditions.*;
import static gu.sql2java.observer.JDBCUtility.getColumnNames;
import static gu.sql2java.observer.JDBCUtility.getColumnTypes;
import static gu.sql2java.observer.JDBCUtility.getSqlTypes;
import static gu.sql2java.utils.JDBCUtility.getColumnTypeNames;

import java.sql.DatabaseMetaData;
import java.util.Map;

import gu.sql2java.RowMetaData;
import gu.sql2java.UnnameRow;

/**
 * 简单表元数据,只提供表字段名列表，字段类型等基本数据用于JSON数据反序列化
 * @author guyadong
 *
 */
public class SimpleRowMetaData extends RowMetaData{
	SimpleRowMetaData(DatabaseMetaData  metaData, String tablename, Map<String, Class<?>> targetTypes) {
		super(tablename, 
				"TABLE", 
				UnnameRow.class, 
				null, 
				null, 
				null, 
				getColumnNames(checkNotNull(metaData,"metaData is null"),null,tablename), 
				getColumnTypeNames(checkNotNull(metaData,"metaData is null"),null,tablename), 
				null, 
				null, 
				null, 
				getColumnTypes(metaData,null,tablename,targetTypes), 
				null, getSqlTypes(metaData,null,tablename), null, null, null, null, null, null, null, null);
	}
}